package servlet;

import bean.park.map.ParkMapBean;

import util.DealParams;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

@WebServlet("/park/map")
public class ParkMapServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        //处理参数 存入map
        Map<String,String> params = DealParams.getParamsMap(req);
        //从处理后的map中获取传入的参数
        double longitude = Double.parseDouble(params.get("longitude"));
        double latitude = Double.parseDouble(params.get("latitude"));
        double longitude_range = Double.parseDouble(params.get("longitude_range"));
        double latitude_range = Double.parseDouble(params.get("latitude_range"));
        ParkMapBean bean = new ParkMapBean();
        PrintWriter out = resp.getWriter();
        out.print(bean.queryParkMap(longitude,latitude,longitude_range,latitude_range));
    }
}
